/**
 * Project Untitled
 */


#ifndef _RENDERER_H
#define _RENDERER_H

#include <QOpenGLFunctions.h>
#include <QOpenGLShaderProgram.h>
#include <QOpenGLVertexArrayObject.h>
#include <QOpenGLBuffer.h>
#include <QMatrix4x4>
#include <map>
#include <memory>

struct Identification {
    QString model;
    unsigned int id;
};
class Renderer: public QOpenGLFunctions {
public: 
    class GLObject {
    public:
        std::unique_ptr<QOpenGLVertexArrayObject> vao;
        std::unique_ptr<QOpenGLBuffer> vbo;
        std::unique_ptr<QOpenGLBuffer> ebo;
        QString tex_set;
    };

    std::unique_ptr<QOpenGLShaderProgram> shader;
    
/**
 * 这个函数本应由Rnederer自主完成：注册模型文件夹下所有的模型和对应纹理集。但是必须在OpenGL上下文下，故单独写出
 * @param model_name
 * @param texs_name
 */
static void registerObject(QString model_name, QString texs_name);
    
void Clear();
    
/**
 * @param world
 * @param Iden
 */
void draw(QMatrix4x4 world, Identification Iden);
    
/**
 * @param Vshader_file_path
 * @param Fshader_file_path
 */
Renderer(QString Vshader_file_path, QString Fshader_file_path);

private: 
    //static std::map<QString, GLObject> models;
};

#endif //_RENDERER_H